package com.yuntsg.nnsfcp.config;

/**
 * SpringTaskConfig
 *
 * @author ：ljx
 * @date ：Created in 2019/6/17
 */
//@Configuration
//@EnableAsync
public class AsyncConfig /*implements SchedulingConfigurer*/ {
    /**
     * `@EnableAsync：开启异步事件的支持`
     *
     * 然后在定时任务的类或者方法上添加@Async 。最后重启项目，每一个任务都是在不同的线程中
     */
    /*此处成员变量应该使用@Value从配置中读取*/
    /*private int corePoolSize = 10;
    private int maxPoolSize = 200;
    private int queueCapacity = 10;
    *//**线程池中任务的等待时间，如果超过这个时候还没有销毁就强制销毁*//*
    private final int AWAIT_TERMINATION = 120;

    @Bean("taskExecutor")
    public Executor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(corePoolSize);
        executor.setMaxPoolSize(maxPoolSize);
        executor.setQueueCapacity(queueCapacity);
        executor.setAwaitTerminationSeconds(AWAIT_TERMINATION);
        executor.initialize();
        return executor;
    }*/

//    @Bean
//    public Executor taskExecutor() {
//        //指定定时任务线程数量，可根据需求自行调节
//        return Executors.newScheduledThreadPool(3);
//    }

//    @Override
//    public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
//        scheduledTaskRegistrar.setScheduler(taskExecutor());
//    }

}